﻿// ------------------------------------------------------------------------------
// <copyright file="ClientWrapper.cs" company="MyCompany.com">
//  Copyright © MyCompany.com. All rights reserved.
// </copyright>
// <author>Me</author>
// ------------------------------------------------------------------------------

namespace BTerrariaMod
{
    using Microsoft.Xna.Framework;
    using Terraria;

    /// <summary>
    /// Wraps the Terraria Client providing extensibility points for modding.
    /// </summary>
    public class ClientWrapper : Terraria.Main
    {
        /// <summary>
        /// Is the broadcast done?
        /// </summary>
        private static bool broadCastDone = false;

        /// <summary>
        /// Initializes a new instance of the <see cref="ClientWrapper"/> class.
        /// </summary>
        /// <param name="args">The args.</param>
        public ClientWrapper(string[] args)
        {
        }

        /// <summary>
        /// Determines whether [is in game].
        /// </summary>
        /// <returns>
        ///   <c>true</c> if [is in game]; otherwise, <c>false</c>.
        /// </returns>
        [ClientCode]
        public bool IsInGame()
        {
            if (!Main.gameMenu)
            {
                return Main.netMode == 0;
            }

            return false;
        }

        /// <summary>
        /// Updates the specified game time.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (this.IsInGame() && broadCastDone == false)
            {
                Main.NewText("yay modding done by B!");
                broadCastDone = true;
            }
        }
    }
}